<?php

namespace App\Http\Requests\Role;

use App\Http\Requests\ApiRequest;

class RoleToUserRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * 'permission/manager_manage/ManagerDataAdd'：前端路由
     *
     * @return bool
     */
    public function authorize()
    {
        if(is_bool(self::checkPermission('permission/manager_manage/ManagerDataAdd'))){
            return self::checkPermission('permission/manager_manage/ManagerDataAdd');
        }else{
            return false;
        }
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'user_id' => 'required|integer',
            'role_ids' => 'array',
        ];
    }

    public function messages()
    {
        return [
            'user_id.required' => '缺少用户ID',
            'user_id.integer' => '用户ID必须为整数',
            'role_ids.array' => '角色ID必须为数组',
        ];
    }
}
